<?php
 
 error_reporting(E_ALL);
 ini_set("display_errors", 1);
 
class security
{
    private $_db;
    public function __construct($db=NULL)
    {
        if(is_object($db))
        {
            $this->_db = $db;
        }
        else
        {
            $dsn = "mysql:host=".DB_HOST.";dbname=".DB_NAME;
            $this->_db = new PDO($dsn, DB_USER, DB_PASS);
        }
    }
	
	public function ifContainsSpace($string){
		if ( preg_match('/\s/',$string) ){
			return true;	
		}
		return false;
	}
	
	public function isNumeric($string){
		if(is_numeric($string)) return true;
		return false;
	}
	
	public function isAlpha($string){
		if(ctype_alpha($string)) return true;
		return false;
	}
	
	public function isEmail($string){
		if(filter_var($string, FILTER_VALIDATE_EMAIL)) {
        	return true;
    	}
    	else {
        	return false;
    	}	
	}
	
}